package 富婆梦.第一阶段.第七周IO流;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.LinkedList;

/**
 * @ProjectName: java-learning
 * @Package: 富婆梦.第一阶段.第七周
 * @ClassName: Exercise7
 * @Author: hemengjin
 * @Description: 打开一个文件，读取内容，将每一行的内容存在ArrayList里面，反向打印ArrayList
 * @Date:2021/9/8 18:49
 * @Version: 1.0
 */
public class TestBufferReader {
    public static void main(String[] args) {
        File file = new File("D:/何梦锦的宝藏/Java学习/1.txt");
        try {
            FileReader fr = new FileReader(file);
            BufferedReader in = new BufferedReader(fr);
            LinkedList<String> list = new LinkedList<>();
            String s;
            //list.add("红酥手");
            while ((s=in.readLine())!=null){
                list.add(s);
            }
            for (String sr:list) {
                System.out.println(sr);
            }
        }catch (Exception e){
            e.printStackTrace();
        }



    }
}
